package io.github.harmonly.mapper;

import io.github.harmonly.entity.association.Member;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MemberMapper {

    @Select("select * from member")
    List<Member> getMembers();

    @Select("select * from member where aid = #{aid}")
    List<Member> getMembersByAssociation(int aid);

    @Select("select * from member where uid = #{uid}")
    List<Member> getMembersByUser(int uid);

    @Select("select * from member where uid = #{uid} and aid = #{aid}")
    Member isJoin(Member member);

    @Insert("insert into member(uid, aid) VALUES (#{uid}, #{aid})")
    int addMember(Member member);

    @Delete("delete member from member where uid = #{uid} and aid = #{aid}")
    int deleteMember(Member member);
}
